package com.algorithm;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: sun.hongliang
 * @create: 2019/11/20 16:30
 */
public class IsPalindrome {

    public static void main(String[] args) {

    }

    public boolean isPalindrome(ListNode head) {
        ListNode p = head;
        List<ListNode> listNodes = new ArrayList<>();
        while (p != null) {
            listNodes.add(p);
            p = p.next;
        }
        int len = listNodes.size();
        for (int i = 0; i < len / 2; i++) {
            if (listNodes.get(i).val != listNodes.get(len - 1 - i).val) {
                return false;
            }
        }
        return true;
    }
}
